﻿#include "SkillDescEx.h"

#include <DescStore/SkillSlotDesc.h>

SkillDescEx::SkillDescEx()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

SkillDescEx::~SkillDescEx()
{
}

int SkillDescEx::CreateInit()
{
    return 0;
}

int SkillDescEx::ResumeInit()
{
    return 0;
}

int SkillDescEx::Load()
{
    return 0;
}

int SkillDescEx::CheckWhenAllDataLoaded()
{
    m_iExSkillSlotIndex.clear();
    auto &vecSkillDesc = SkillSlotDesc::Instance()->GetResDesc();
    for (int i = 0; i < (int) vecSkillDesc.size(); i++)
    {
        auto &desc = vecSkillDesc[i];
        CHECK_EXPR(IS_VALID_SLOT_TYPE(desc.type), -1, "ID:{}  invalid slot type:{}", desc.id, desc.type);
        if (desc.type == proto_ff::EN_SKILL_SLOT_TYPE_EXPERIENCE)
        {
            CHECK_EXPR(m_iExSkillSlotIndex.size() < m_iExSkillSlotIndex.max_size(), -1, "ex skill slot is fulled!");

            m_iExSkillSlotIndex.push_back(desc.id - 1);
        }
    }
    return 0;
}

int SkillDescEx::GetExSkillSlot(int iIdx) const
{
    if (iIdx >= 0 && iIdx < (int) m_iExSkillSlotIndex.size())
    {
        return m_iExSkillSlotIndex[iIdx];
    }

    return -1;
}
